package com.ms.demo.demo2;

/**
 * @description: 创建球员类
 * @author: ms
 * @create: 2022-10-27 17:17
 */
public class Player {

    private String name;

    private int total;

    public Player(String name) {
        this.name = name;
        this.total = 0;
    }

    /**
     * 总得分
     */
    public void getTotal() {
        System.out.println(name + "目前得分：" + total);
    }

    /**
     * 进球
     */
    public void score(Score score) {
        System.out.println(name + "投进了一个" + score.point + "分球。");
        total += score.point;
    }


    /**
     * 计分错了，去掉得分
     */
    public void undo(Score score) {
        System.out.println(name + "之前投进的一个" + score.point + "分球无效。");
        total -= score.point;
    }
}